package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.BookMarkQueryVo;
import cn.ywsj.ywsjmidtier.entity.VO.BookMarkVo;
import cn.ywsj.ywsjmidtier.service.WechatBookmarkFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName : WechatBookmarkController
 * @Author : Lenovo
 * @Date: 2021/7/21 15:21
 * @Description :
 */
@Api(tags = "关注")
@RestController
@RequestMapping("/wechat")
public class WechatBookmarkController {
    @Autowired
    private WechatBookmarkFeign wechatBookmarkFeign;

    /**
     * 商品关注和店铺关注列表
     * @param bookMarkQueryVo
     * @param start
     * @param pageSize
     * @return
     */
    @ApiOperation("商品关注和店铺关注列表")
    @PostMapping("/member/bookmarkmgr/collectmanagelist")
    public String collectManageList(BookMarkQueryVo bookMarkQueryVo,Integer start,Integer pageSize){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bookMarkQueryVo);
        return wechatBookmarkFeign.collectManageList(jsonObject,start,pageSize);
    }

    /**
     * 取消商品关注和店铺关注
     * @param bookMarkVo
     * @param result
     * @return
     */
    @ApiOperation("取消商品关注和店铺关注")
    @PostMapping("/bookmarkmgr/ajaxupdateproductbookmark")
    public String ajaxupdateproductbookmark(BookMarkVo bookMarkVo, BindingResult result){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bookMarkVo);
        return wechatBookmarkFeign.ajaxupdateproductbookmark(jsonObject,result);
    }
    @PostMapping("/member/bookmarkmgr/queryproductbookmark")
    public String queryProductBookMark(BookMarkQueryVo bookMarkQueryVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bookMarkQueryVo);
        return wechatBookmarkFeign.queryProductBookMark(jsonObject);
    }
    @PostMapping("/bookmarkmgr/addproductbookmark")
    public String addProductBookMark(BookMarkVo bookMarkVo,BindingResult result){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bookMarkVo);
        return wechatBookmarkFeign.addProductBookMark(jsonObject,result);
    }
    @PostMapping("/member/bookmarkmgr/ajaxdelbookmark")
    public String ajaxDelBookMark(BookMarkVo bookMarkVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bookMarkVo);
        return wechatBookmarkFeign.ajaxDelBookMark(jsonObject);
    }
    @PostMapping("/bookmarkmgr/ajaxupdateproductbookmarklist")
    public String ajaxUpdateProductBookMarkList(BookMarkVo bookMarkVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bookMarkVo);
        return wechatBookmarkFeign.ajaxUpdateProductBookMarkList(jsonObject);
    }

    @GetMapping("/member/bookmarkmgr/queryproductbookmarkcount")
    public String queryProductBookMarkCount(BookMarkQueryVo bookMarkQueryVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bookMarkQueryVo);
        return wechatBookmarkFeign.queryProductBookMarkCount(jsonObject);
    }
}
